/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package creature;

import java.awt.Color;
import world.World;

/**
 *
 * @author leadiv
 *  By Default a creature is a small green 1 pixel dot that runs east to west.
 */
public class Spore4 extends Creature {

    public Spore4(int x, int y, int id) {
        super(x,y,id);
        this.setSkinColor(new Color(255, 128, 172));
    }
    
    @Override
    public void move(World w) 
    {
        Color spore3 = new Color(255, 128, 172);
        Color spore4 = this.getSkinColor();
        
        if (w.getpix(this.getX() - 1, this.getY() - 1).equals(Color.BLACK) && w.getpix(this.getX() + 1, this.getY() - 1).equals(Color.BLACK) && w.getpix(this.getX(), this.getY() - 1).equals(Color.BLACK)) w.place(this.getX(), this.getY() - 1, this.getId());
        else if (w.getpix(this.getX() + 1, this.getY()).equals(spore3) && !w.getpix(this.getX() + 1, this.getY() + 1).equals(Color.BLACK)) w.place(this.getX(), this.getY() + 1, this.getId());
        else if (w.getpix(this.getX() + 1, this.getY()).equals(spore3) && w.getpix(this.getX() + 1, this.getY() + 1).equals(Color.BLACK)) w.place(this.getX() + 1, this.getY() + 1, this.getId());
        else if (w.getpix(this.getX() - 1, this.getY()).equals(spore4) && !w.getpix(this.getX() - 1, this.getY() + 1).equals(Color.BLACK)) w.place(this.getX(), this.getY() + 1, this.getId());
        else if (w.getpix(this.getX() - 1, this.getY()).equals(spore4) && w.getpix(this.getX() - 1, this.getY() + 1).equals(Color.BLACK)) w.place(this.getX() - 1, this.getY() + 1, this.getId());
        else w.place(this.getX() + (int)(Math.random() * 3) - 1, this.getY(), this.getId());
    }
}
